#!./bin/python
# ----------------------------------------------------------------------
# Generate clickhouse dictionaries
# ----------------------------------------------------------------------
# Copyright (C) 2007-2017 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------

# Python modules
import os
import sys
# NOC modules
from noc.core.clickhouse.dictionary import Dictionary
from noc.core.fileutils import safe_rewrite


def main(path):
    for dc in Dictionary.iter_cls():
        xml = dc.get_config()
        safe_rewrite(
            os.path.join(path, "%s.xml" % dc._meta.name),
            xml
        )


if __name__ == "__main__":
    main(sys.argv[1])
